 							--[################# HEADER #################]--
AddCSLuaFile("cl_init.lua");
AddCSLuaFile("shared.lua");
include("shared.lua");




								--[################# SENT CODE ###############]--

/******************************************************/
/***************This is activated on Spawn****************/
/******************************************************/
function ENT:Initialize()
	
	local giveRes = 
	{
		{resName = "titanium", resMin = 1000, resMax = 3500},
		{resName = "redterracrystal", resMin = 1000,  resMax = 5000},
		{resName = "greenterracrystal", resMin = 1000,  resMax = 5000},
	}
	
	local x = 0 -- This is for later
	
//Adds resources to the entity
	for k,v in pairs(giveRes) do
		local inc = math.random(v.resMin, v.resMax)
		RD_AddResource(self, v.resName, inc)
		RD_SupplyResource(self, v.resName, inc) 
	end
	
	//Sets all the physics variables
	self.Entity:PhysicsInit(MOVETYPE_VPHYSICS)
	self.Entity:SetMoveType(MOVETYPE_VPHYSICS);
	self.Entity:SetSolid(SOLID_VPHYSICS);
	timer.Simple(10, function(phys) phys:EnableMotion(false) end, phys) -- No more randomly spinning asteriods in space
	timer.Simple(11, function(phys) phys:EnableMotion(true) end, phys) -- No more randomly spinning asteriods in space
	if not (WireAddon == nil) then
		self.WireDebugName = self.PrintName
		self.Outputs = Wire_CreateOutputs(self.Entity, { "Remaining Titinium: ", "Remaining Terra-Crystals (Red)", "Remaining Terra-Crystals (Green)"})
	end
end

			


--Before we start spawning asteroids we need to locate an area for them to be--
//local self.envPick = math.random(1, table.getn(self.environments))
//local self.env = self.environments[self.envPick]


//Now lets make it have a planet orbit
-- function RotateAround( object, base, angle, rad )
	-- local pos1 = base
	-- local x = math.cos( math.rad( angle ) ) * rad
	-- local y = math.sin( math.rad( angle ) ) * rad
	-- pos1.x = pos1.x + x
	-- pos1.y = pos1.y + y
	-- object:SetPos( pos1 )
-- end
-- timer.Create( "Asteroid Timer1", 0.1, 999999999999999999999999^999999999999999999, RotateAround, self, self.env.pos, 10, (enc.radius +200))
 


function ENT:PhysicsUpdate( phys )
	
end 


/******************************************************/
/****This is the Think Function (carried out every interval)****/
/******************************************************/
function ENT:Think()

	Wire_TriggerOutput(self.Entity, "Remaining Titinium: ", RD_GetResourceAmount(self, "titanium"))
	Wire_TriggerOutput(self.Entity, "Remaining Terra-Crystals (Red)", RD_GetResourceAmount(self, "redterracrystal"))
	Wire_TriggerOutput(self.Entity, "Remaining Terra-Crystals (Green)", RD_GetResourceAmount(self, "greenterracrystal"))
	
	self.Entity:NextThink(CurTime()+0.5);
	return true;
end




